#include<iostream>
using namespace std;
int h[250001];
int stack[250001];
int main(){
    int n;
    cin>>n;
     int a;
     int top=0;
     long long ans=0;
    for(int i=1;i<=n;i++){
       
        cin>>a>>h[i];
        while(top&&h[i]<stack[top])
        {
            top--;
        }
        if(!top||h[i]>stack[top]){
            ans++;
            stack[++top]=h[i];
        }
    }
    cout<<ans;
}